<?php
/**
 *
 * User: Feng
 * Date: 2024/05/28
 */

namespace app\web\controller;

use app\common\controller\Web;
use app\common\model\Link;
use app\common\model\ProductAbility;
use app\common\model\ProductChallenge;
use app\common\model\ProductObject;

/**
 * 核心产品
 * User: Feng
 * Date: 2024/05/28
 * @package app\home\controller
 */
class Product extends Web
{
	public function extreme_flow()
	{
		$id = $this->request->param('id');
		$this->_common($id);
		$employ = (new Link())->get(['position' => 3]);
		$this->assign('employ', $employ);
		return view('extreme_flow', [
			'product_sparkle_p1'  => getSetting('product_sparkle_p1'),
			'product_sparkle_p2'  => getSetting('product_sparkle_p2'),
			'product_sparkle_p3'  => getSetting('product_sparkle_p3'),
			'product_sparkle_p4'  => getSetting('product_sparkle_p4'),
			'product_sparkle_p5'  => getSetting('product_sparkle_p5'),
			'product_sparkle_p6'  => getSetting('product_sparkle_p6'),
			'product_sparkle_p7'  => getSetting('product_sparkle_p7'),
			'product_sparkle_p8'  => getSetting('product_sparkle_p8'),
			'product_sparkle_p9'  => getSetting('product_sparkle_p9'),
			'product_sparkle_pic' => _sImage(getSetting('product_sparkle_pic')),
		]);
	}

	public function extreme_stars()
	{
		$id = $this->request->param('id');
		$this->_common($id);
		$employ = (new Link())->get(['position' => 4]);
		$this->assign('employ', $employ);
		return view('extreme_stars', [
			'product_character_desc'  => getSetting('product_character_desc'),
			'product_character_p1'    => getSetting('product_character_p1'),
			'product_character_pic1'  => _sImage(getSetting('product_character_pic1')),
			'product_character_desc1' => getSetting('product_character_desc1'),
			'product_character_p2'    => getSetting('product_character_p2'),
			'product_character_pic2'  => _sImage(getSetting('product_character_pic2')),
			'product_character_desc2' => getSetting('product_character_desc2'),
		]);
	}

	public function smart_labeling()
	{
		$id = $this->request->param('id');
		$this->_common($id);
		$employ = (new Link())->get(['position' => 5]);
		$this->assign('employ', $employ);
		return view('smart_labeling', [
			'product_superiority_t1'    => getSetting('product_superiority_t1'),
			'product_superiority_t2'    => getSetting('product_superiority_t2'),
			'product_superiority_t3'    => getSetting('product_superiority_t3'),
			'product_superiority_desc1' => getSetting('product_superiority_desc1'),
			'product_superiority_desc2' => getSetting('product_superiority_desc2'),
			'product_superiority_desc3' => getSetting('product_superiority_desc3'),
			'product_merit_p1'          => getSetting('product_merit_p1'),
			'product_merit_desc1'       => getSetting('product_merit_desc1'),
			'product_merit_pic1'        => _sImage(getSetting('product_merit_pic1')),
			'product_merit_p2'          => getSetting('product_merit_p2'),
			'product_merit_desc2'       => getSetting('product_merit_desc2'),
			'product_merit_pic2'        => _sImage(getSetting('product_merit_pic2')),
			'product_advantage_t1'      => getSetting('product_advantage_t1'),
			'product_advantage_desc1'   => getSetting('product_advantage_desc1'),
			'product_advantage_pic1'    => _sImage(getSetting('product_advantage_pic1')),
			'product_advantage_t2'      => getSetting('product_advantage_t2'),
			'product_advantage_desc2'   => getSetting('product_advantage_desc2'),
			'product_advantage_pic2'    => _sImage(getSetting('product_advantage_pic2')),
			'product_advantage_t3'      => getSetting('product_advantage_t3'),
			'product_advantage_desc3'   => getSetting('product_advantage_desc3'),
			'product_advantage_pic3'    => _sImage(getSetting('product_advantage_pic3')),
			'product_ability_t1'    => getSetting('product_ability_t1'),
			'product_ability_desc1' => getSetting('product_ability_desc1'),
			'product_ability_icon1' => _sImage(getSetting('product_ability_icon1')),
			'product_ability_pic1'  => _sImage(getSetting('product_ability_pic1')),
			'product_ability_img1'  => _sImage(getSetting('product_ability_img1')),
			'product_ability_t2'    => getSetting('product_ability_t2'),
			'product_ability_desc2' => getSetting('product_ability_desc2'),
			'product_ability_icon2' => _sImage(getSetting('product_ability_icon2')),
			'product_ability_pic2'  => _sImage(getSetting('product_ability_pic2')),
			'product_ability_img2'  => _sImage(getSetting('product_ability_img2')),
			'product_ability_t3'    => getSetting('product_ability_t3'),
			'product_ability_desc3' => getSetting('product_ability_desc3'),
			'product_ability_icon3' => _sImage(getSetting('product_ability_icon3')),
			'product_ability_pic3'  => _sImage(getSetting('product_ability_pic3')),
			'product_ability_img3'  => _sImage(getSetting('product_ability_img3')),
			'product_ability_t4'    => getSetting('product_ability_t4'),
			'product_ability_desc4' => getSetting('product_ability_desc4'),
			'product_ability_icon4' => _sImage(getSetting('product_ability_icon4')),
			'product_ability_pic4'  => _sImage(getSetting('product_ability_pic4')),
			'product_ability_img4'  => _sImage(getSetting('product_ability_img4')),
			'product_ability_t5'    => getSetting('product_ability_t5'),
			'product_ability_desc5' => getSetting('product_ability_desc5'),
			'product_ability_icon5' => _sImage(getSetting('product_ability_icon5')),
			'product_ability_pic5'  => _sImage(getSetting('product_ability_pic5')),
			'product_ability_img5'  => _sImage(getSetting('product_ability_img5')),
			'product_ability_t6'    => getSetting('product_ability_t6'),
			'product_ability_desc6' => getSetting('product_ability_desc6'),
			'product_ability_icon6' => _sImage(getSetting('product_ability_icon6')),
			'product_ability_pic6'  => _sImage(getSetting('product_ability_pic6')),
			'product_ability_img6'  => _sImage(getSetting('product_ability_img6')),
		]);
	}

	private function _common($id)
	{
		$product = (new \app\common\model\Product())->get($id);
		$product['pic'] = _sImage($product['pic']);
		//服务对象
		$object = (new ProductObject())->where(['product_id' => $id])->select();
		foreach ($object as $item) {
			$item['pic'] = _sImage($item['pic']);
		}
		//痛点挑战
		$challenge = (new ProductChallenge())->where(['product_id' => $id])->select();
		foreach ($challenge as $item) {
			$item['pic'] = _sImage($item['pic']);
		}
		//ability 核心功能
		$ability = (new ProductAbility())->where(['product_id' => $id])->select();
		foreach ($ability as $item) {
			$item['pic'] = _sImage($item['pic']);
			$item['pic1'] = _sImage($item['pic1']);
			$item['pic2'] = _sImage($item['pic2']);
		}
		$this->assign('product', $product);
		$this->assign('object', $object);
		$this->assign('challenge', $challenge);
		$this->assign('ability', $ability);
	}
}